<template>
 <li @mouseenter="moveInItem" @mouseleave="moveOutItem" :class="{active:isShow}">
    <label>
      <input type="checkbox" :checked="todo.isOver"  @click="changeOneTo"/>
      <span>{{todo.content}}</span>
    </label>
    <button class="btn btn-danger" v-show="isShow" @click="deleteOneTo">删除</button>
  </li>
</template>
<script>

export default {
  name: 'Item',
  props:['todo',"changeOneTodo","index","deleteOneTodo"],
  data() {
    return {
      isShow: false
    };
  },
  methods:{
    moveInItem(){
      this.isShow = true
    },
    moveOutItem(){
      this.isShow = false
    },
    changeOneTo(){
      this.changeOneTodo(this.todo)
    },
    deleteOneTo(){
      this.deleteOneTodo(this.index)
    }
  }
}
</script>

<style scoped>
/*item*/
li {
  list-style: none;
  height: 36px;
  line-height: 36px;
  padding: 0 5px;
  border-bottom: 1px solid #ddd;
}

li.active {
  background-color: red;
}

li label {
  float: left;
  cursor: pointer;
}

li label li input {
  vertical-align: middle;
  margin-right: 6px;
  position: relative;
  top: -1px;
}

li button {
  float: right;
  
  margin-top: 3px;
}

li:before {
  content: initial;
}

li:last-child {
  border-bottom: none;
}

</style>
